<?php

/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * @Date: 2022-04-21 15:27:09
 * @LastEditors: Sam
 * @LastEditTime: 2022-04-27 21:44:10
 */
use think\facade\Db;
use app\admin\model\AuthRule as AuthRuleModel;

if (!AuthRuleModel::where('title', '资讯通知')->count()) {

    $parent_id = AuthRuleModel::query()->create([
        'parent_id'    => 0,
        'title'        => '资讯管理',
        'url'          => '#',
        'method'       => 'OPTIONS',
        'slug'         => 'notice'
    ]);
   $parent_id_1 =   AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '资讯列表',
        'url'          => 'notice_index',
        'method'       => 'GET',
        'slug'         => 'notice.index'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '添加资讯',
        'url'          => 'notice_create',
        'method'       => 'POST',
        'slug'         => 'notice.create'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '编辑资讯',
        'url'          => 'notice_edit',
        'method'       => 'POST',
        'slug'         => 'notice.edit'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '删除资讯',
        'url'          => 'notice_delete',
        'method'       => 'POST',
        'slug'         => 'notice.delete'
    ]);

  $parent_id_2 =   AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '资讯分类',
        'url'          => 'noticeType_index',
        'method'       => 'GET',
        'slug'         => 'noticeType.index'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_2->id,
        'title'        => '添加资讯分类',
        'url'          => 'noticeType_create',
        'method'       => 'POST',
        'slug'         => 'noticeType.create'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_2->id,
        'title'        => '编辑资讯分类',
        'url'          => 'noticeType_edit',
        'method'       => 'POST',
        'slug'         => 'noticeType.edit'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_2->id,
        'title'        => '删除资讯分类',
        'url'          => 'noticeType_delete',
        'method'       => 'POST',
        'slug'         => 'noticeType.delete'
    ]);
}












